package com.bright.ghj.overt.repository.primary;

import com.bright.ghj.overt.pojo.po.primary.Dist;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DistRepository extends JpaRepository<Dist, Integer>, JpaSpecificationExecutor<Dist> {

    List<Dist> findAllByDistNo(String distNo);

    @Query("from Dist where trim(distName) =:distName")
    List<Dist> findAllByDistName(@Param("distName") String distName);

    @Query("from Dist where distNo like :distNo% and length(distNo)=:distNoLength order by distNo")
    List<Dist> findAllByDistNoAndLength(@Param("distNo") String distNo, @Param("distNoLength") int distNoLength);

//    @Query("from Dist where distNo like :distNo% and distNo like :userDistNo% and length(distNo)=:distNoLength order by distNo")
//    List<Dist> findAllByDistNoAndLength(@Param("distNo") String distNo, @Param("distNoLength") int distNoLength, @Param("userDistNo") String userDistNo);

}